package com.retail.order.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.order.entity.request.SysAdminVerifyDetailRequest;
import com.retail.order.entity.vo.SysAdminVerifyDetailVo;
import com.retail.order.service.SysAdminVerifyDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 用户核销单子明细 API
* @author Administrator
*/
@Api(tags = "用户核销单子明细 API")
@RestController
@RequestMapping("/sysAdminVerifyDetail")
public class SysAdminVerifyDetailController extends AbstractCommonController<SysAdminVerifyDetailService, SysAdminVerifyDetailRequest, SysAdminVerifyDetailVo>{

    @Autowired
    private SysAdminVerifyDetailService sysAdminVerifyDetailService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(sysAdminVerifyDetailService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存用户核销单子明细")
    public Result<Integer> save(@RequestBody SysAdminVerifyDetailRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(sysAdminVerifyDetailService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新用户核销单子明细")
    public Result<Integer> update(@RequestBody SysAdminVerifyDetailRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(sysAdminVerifyDetailService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("用户核销单子明细-查询")
    public Result<List<SysAdminVerifyDetailVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(sysAdminVerifyDetailService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("用户核销单子明细-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(sysAdminVerifyDetailService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("用户核销单子明细-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<SysAdminVerifyDetailRequest> req) {
        return super.page(sysAdminVerifyDetailService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除用户核销单子明细")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(sysAdminVerifyDetailService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除用户核销单子明细")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(sysAdminVerifyDetailService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
